package com.example.demo.mapper;

import com.example.demo.pojo.Pets;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface PetsMapper {
	@Select("select * from pets where goodsID=#{goodsID}")
	List<Pets> findByID(Integer goodsID);
	@Select("select * from pets where goodsID=#{goodsID}")
	Pets findByGoodsID(Integer goodsID);
	@Select("select * from pets")
	List<Pets> findAll();
	@Select("SELECT * FROM pets WHERE goodsName LIKE CONCAT('%', #{goodsName}, '%')")
	List<Pets> findByName(String goodsName);

	@Select("<script>" +
			"SELECT * FROM pets WHERE goodsID IN " +
			"<foreach item='item' index='index' collection='goodsIDs' open='(' separator=',' close=')'>" +
			"#{item}" +
			"</foreach>" +
			"</script>")
	List<Pets> findGoodsByIDs(@Param("goodsIDs") List<Integer> goodsIDs);



	@Update("UPDATE pets SET goodsSum=#{goodsSum}  WHERE goodsID = #{goodsID}")
	void updateByID(Pets product);

	@Select("select * from pets where sellerID=#{sellerID}")
	List<Pets> findBySellerID(Integer sellerID);
}
